package com.mall.common.utils;

import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;

/**
 * @author: 谢君臣
 * @Date: 2022/7/26-11:11
 * @version: 1.0
 * @function:
 */
public class ParamUtils {
    private static final long serialVersionUID = 11234234234L;

    public static BigDecimal strParseBigDecimal(Object str) {
        String temp = (String) str;
        if (str == null || StringUtils.isEmpty(temp))
            return new BigDecimal("0");
        else
            try {
                return new BigDecimal(temp);
            } catch (Exception e) {
                return new BigDecimal("0");
            }
    }
    public static String strParseString(Object str) {
        String temp = (String) str;
        if (str == null )
            temp = "";
        return temp;
    }

    public static Long strParseLong(Object str) {
        String temp = (String) str;
        if (str == null )
            return 0L;
        try {
            return Long.parseLong(temp);
        } catch (NumberFormatException e) {
            return 0L;
        }
    }
}
